package com.gongyibao.gbase.service;

import com.alicp.jetcache.anno.*;
import com.gongyibao.gbase.common.constant.CacheConst;
import com.gongyibao.gbase.entity.TUser;

public interface TUserService {
    /**
     * 加入缓存
     *
     * @param id
     * @return
     */
    @Cached(name = "Gbase:userInfo", key = "#id", cacheType = CacheType.BOTH, expire = CacheConst.REFRESH_TIME)
    @CacheRefresh(refresh = CacheConst.REFRESH_TIME, stopRefreshAfterLastAccess = CacheConst.REFRESH_TIMEOUT)
    TUser getUserById(Integer id);

    Boolean insertUser(TUser user);

    /**
     * 更新用户信息及缓存
     *
     * @param user
     * @return
     */
    @CacheUpdate(name = "Gbase:userInfo", key = "#user.id", value = "#user")
    Boolean updateUser(TUser user);

    /**
     * 删除用户及缓存失效
     *
     * @param id
     * @return
     */
    @CacheInvalidate(name = "Gbase:userInfo", key = "#id")
    Boolean delUser(Integer id);

}